import api from '../api'
import { LocalStorage } from 'quasar'

export default ({ app, router, Vue }) => {
  Vue.prototype.$api = api;
  router.beforeEach((to, from, next) => {
    /*
    if(to.path == '/login') {
      LocalStorage.remove('account');
    }*/
    if(to.query['_account']) {      
      try {
        let account = JSON.parse(decodeURI(to.query['_account'])); 
        api.account.initAccount(account);
      } catch(e) {
        console.log(e);
      }
    }
    api.ui.init();
    next();
  });
}